<?php


class expedientes extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'expedientes';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('EXP_N, EXP_A, fojas, ocupanteDoc, barrFis, barrPos, codPos, nota_id, CALLE1, CALLE2, ALTCF1, ALTCF2, ESTADO_ID, UBICACION_ID', 'numerical', 'integerOnly'=>true),
			array('caratula', 'length', 'max'=>150),
			array('SUPTER, DPTO, CIRCUN, CHACRA, QUINTA, MANZ, PARCELA', 'length', 'max'=>5),
			array('SECCION, CONCILIADO', 'length', 'max'=>2),
			array('FRACCION', 'length', 'max'=>6),
			array('EXP_E, EXP_L', 'length', 'max'=>50),
			array('FechaInicio, FECHAREAL', 'safe'),

			array('id, EXP_N, EXP_A, fojas, caratula, ocupanteDoc, barrFis, barrPos, codPos, nota_id, FechaInicio, SUPTER, DPTO, CIRCUN, SECCION, CHACRA, QUINTA, FRACCION, MANZ, PARCELA, CALLE1, CALLE2, ALTCF1, ALTCF2, FECHAREAL, EXP_E, ESTADO_ID, UBICACION_ID, EXP_L, CONCILIADO', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'emovimientos' => array(self::HAS_MANY, 'Emovimiento', 'expedientes_id'),
			'eSTADO' => array(self::BELONGS_TO, 'Estado', 'ESTADO_ID'),
			'nota' => array(self::BELONGS_TO, 'Notas', 'nota_id'),
			'uBICACION' => array(self::BELONGS_TO, 'Ubicacion', 'UBICACION_ID'),
			'ocupanteDoc0' => array(self::BELONGS_TO, 'Personas', 'ocupanteDoc'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'Id',
			'EXP_N' => 'Numero',
			'EXP_A' => 'Año',
			'fojas' => 'Fojas',
			'caratula' => 'Caratula',
			'ocupanteDoc' => 'Docuemento',
			'barrFis' => 'Barr Fis',
			'barrPos' => 'Barr Pos',
			'codPos' => 'Cod Pos',
			'nota_id' => 'Nota',
			'FechaInicio' => 'Fecha Inicio',
			'SUPTER' => 'Supterficie',
			'DPTO' => 'Dpto',
			'CIRCUN' => 'Circun',
			'SECCION' => 'Seccion',
			'CHACRA' => 'Chacra',
			'QUINTA' => 'Quinta',
			'FRACCION' => 'Fraccion',
			'MANZ' => 'Manz',
			'PARCELA' => 'Parcela',
			'CALLE1' => 'Calle1',
			'CALLE2' => 'Calle2',
			'ALTCF1' => 'Altcf1',
			'ALTCF2' => 'Altcf2',
			'FECHAREAL' => 'Fecha Real',
			'EXP_E' => 'Exp E',
			'ESTADO_ID' => 'Estado',
			'UBICACION_ID' => 'Despacho',
			'EXP_L' => 'Despacho',
			'CONCILIADO' => 'Conciliado',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;
		$criteria->compare('id',$this->id);
		$criteria->compare('EXP_N',$this->EXP_N);
		$criteria->compare('EXP_A',$this->EXP_A);
		$criteria->compare('fojas',$this->fojas);
		$criteria->compare('caratula',$this->caratula,true);
		$criteria->compare('ocupanteDoc',$this->ocupanteDoc);
		$criteria->compare('barrFis',$this->barrFis);
		$criteria->compare('barrPos',$this->barrPos);
		$criteria->compare('codPos',$this->codPos);
		$criteria->compare('nota_id',$this->nota_id);
		$criteria->compare('FechaInicio',$this->FechaInicio,true);
		$criteria->compare('SUPTER',$this->SUPTER,true);
		$criteria->compare('DPTO',$this->DPTO,true);
		$criteria->compare('CIRCUN',$this->CIRCUN,true);
		$criteria->compare('SECCION',$this->SECCION,true);
		$criteria->compare('CHACRA',$this->CHACRA,true);
		$criteria->compare('QUINTA',$this->QUINTA,true);
		$criteria->compare('FRACCION',$this->FRACCION,true);
		$criteria->compare('MANZ',$this->MANZ,true);
		$criteria->compare('PARCELA',$this->PARCELA,true);
		$criteria->compare('CALLE1',$this->CALLE1);
		$criteria->compare('CALLE2',$this->CALLE2);
		$criteria->compare('ALTCF1',$this->ALTCF1);
		$criteria->compare('ALTCF2',$this->ALTCF2);
		$criteria->compare('FECHAREAL',$this->FECHAREAL,true);
		$criteria->compare('EXP_E',$this->EXP_E,true);
		$criteria->compare('ESTADO_ID',$this->ESTADO_ID);
		$criteria->compare('UBICACION_ID',$this->UBICACION_ID);
		$criteria->compare('EXP_L',$this->EXP_L,true);
		$criteria->compare('CONCILIADO',$this->CONCILIADO,true);
                
               
                
                   
                $criteria->order = 'EXP_A desc';

		return new CActiveDataProvider('expedientes', array(
			'criteria'=>$criteria,
		));
	}
        
        

	/**
	 * Returns the static model of the specified AR class.
	 * @return expedientes the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}